'''
Created on Aug 21, 2013

@author: dewey
'''

class NmeaTalkerDict(object):
    TALKERS = dict( AG="Autopilot - General",
                    AP="Autopilot - Magnetic",
                    CC="Computer - Programmed Calculator (obsolete)",
                    CD="Communications - Digital Selective Calling (DSC)",
                    CM="Computer - Memory Data (obsolete)",
                    CS="Communications - Satellite",
                    CT="Communications - Radio-Telephone (MF/HF)",
                    CV="Communications - Radio-Telephone (VHF)",
                    CX="Communications - Scanning Receiver",
                    DE="DECCA Navigation (obsolete)",
                    DF="Direction Finder",
                    EC="Electronic Chart Display & Information System (ECDIS)",
                    EP="Emergency Position Indicating Beacon (EPIRB)",
                    ER="Engine Room Monitoring Systems",
                    GP="Global Positioning System (GPS)",
                    HC="Heading - Magnetic Compass",
                    HE="Heading - North Seeking Gyro",
                    HN="Heading - Non North Seeking Gyro",
                    II="Integrated Instrumentation",
                    IN="Integrated Navigation",
                    LA="Loran A (obsolete)",
                    LC="Loran C (obsolete)",
                    MP="Microwave Positioning System (obsolete)",
                    OM="OMEGA Navigation System (obsolete)",
                    OS="Distress Alarm System (obsolete)",
                    RA="RADAR and/or ARPA",
                    SD="Sounder, Depth", 
                    SN="Electronic Positioning System, other/general",
                    SS="Sounder, Scanning",
                    TI="Turn Rate Indicator",
                    TR="TRANSIT Navigation System",
                    VD="Velocity Sensor, Doppler, other/general",
                    DM="Velocity Sensor, Speed Log, Water, Magnetic",
                    VW="Velocity Sensor, Speed Log, Water, Mechanical",
                    WI="Weather Instruments",
                    YC="Transducer - Temperature (obsolete)",
                    YD="Transducer - Displacement, Angular or Linear (obsolete)",
                    YF="Transducer - Frequency (obsolete)",
                    YL="Transducer - Level (obsolete)",
                    YP="Transducer - Pressure (obsolete)",
                    YR="Transducer - Flow Rate (obsolete)",
                    YT="Transducer - Tachometer (obsolete)",
                    YV="Transducer - Volume (obsolete)",
                    YX="Transducer",
                    ZA="Timekeeper - Atomic Clock",
                    ZC="Timekeeper - Chronometer",
                    ZQ="Timekeeper - Quartz",
                    ZV="Timekeeper - Radio Update, WWV or WWVH")

class NmeaMessageDict(object):
    MESSAGES = {'GNS': 'Fix data',
                'DPT': 'Depth of Water',
                'GST': 'GPS Pseudorange Noise Statistics',
                'DTM': 'Datum Reference',
                'GSV': 'Satellites in view',
                'AAM': 'Waypoint Arrival Alarm',
                'FSI': 'Frequency Set Information',
                'VHW': 'Water speed and heading',
                'GLC': 'Geographic Position, Loran-C',
                'MSS': 'Beacon Receiver Status',
                'PASHR': 'RT300 proprietary roll and pitch sentence',
                'GSA': 'GPS DOP and active satellites',
                'VDR': 'Set and Drift',
                'MSK': 'Control for a Beacon Receiver',
                'GBS': 'GPS Satellite Fault Detection',
                'TPC': 'Trawl Position Cartesian Coordinates',
                'HFB': 'Trawl Headrope to Footrope and Bottom',
                'ZTG': 'UTC & Time to Destination Waypoint',
                'MWV': 'Wind Speed and Angle',
                'DCN': 'Decca Position',
                'HSC': 'Heading Steering Command',
                'PUBX 00': 'uBlox Lat/Long Position Data',
                'PRWIZCH': 'Rockwell Channel Status',
                'OLN': 'Omega Lane Numbers',
                'RMB': 'Recommended Minimum Navigation Information',
                'RMC': 'Recommended Minimum Navigation Information',
                'RMA': 'Recommended Minimum Navigation Information',
                'GGA': 'Global Positioning System Fix Data',
                'TTM': 'Tracked Target Message',
                'PGRME': 'Garmin Estimated Error',
                'ROT': 'Rate Of Turn',
                'OSD': 'Own Ship Data',
                'VLW': 'Distance Traveled through Water',
                'WPL': 'Waypoint Location',
                'PUBX 01': 'uBlox UTM Position Data',
                'RTE': 'Routes',
                'GTD': 'Geographic Location in Time Differences',
                'GRS': 'GPS Range Residuals',
                'VTG': 'Track made good and Ground speed',
                'WCV': 'Waypoint Closure Velocity',
                'PMGNST': 'Magellan Status',
                'STN': 'Multiple Data ID',
                'MTW': 'Mean Temperature of Water',
                'TRF': 'TRANSIT Fix Data',
                'TDS': 'Trawl Door Spread Distance',
                'XTE': 'Cross-Track Error, Measured',
                'TPT': 'Trawl Position True',
                'TPR': 'Trawl Position Relative Vessel',
                'PUBX 03': 'uBlox Satellite Status',
                'R00': 'Waypoints in active route',
                'DBK': 'Depth Below Keel',
                'ALM': 'GPS Almanac Data',
                'TFI': 'Trawl Filling Indicator',
                'PUBX 04': 'uBlox Time of Day and Clock Information',
                'RSD': 'RADAR System Data',
                'RPM': 'Revolutions',
                'RSA': 'Rudder Sensor Angle',
                'VWR': 'Relative Wind Speed and Angle',
                'ITS': 'Trawl Door Spread 2 Distance',
                'LCD': 'Loran-C Signal Data',
                'SFI': 'Scanning Frequency Information',
                'APB': 'Autopilot Sentence "B"',
                'VBW': 'Dual Ground/Water Speed',
                'DBS': 'Depth Below Surface',
                'APA': 'Autopilot Sentence "A"',
                'DBT': 'Depth below transducer',
                'ZFO': 'UTC & Time from origin Waypoint'}

class NmeaFieldsDict(object):
    FIELDS = {      'GNS': ['UTC',
                    'Latitude',
                    'N or S (North or South)',
                    'Longitude',
                    'E or W (East or West)',
                    'Mode indicator',
                    'Total number of satelites in use,00-99',
                    'HDROP',
                    'Antenna altitude, meters, re:mean-sea-level(geoid.',
                    'Goeidal separation meters',
                    'Age of diferential data',
                    'Differential reference station ID',
                    'CRC'],
                    
                    'DPT': ['Depth, meters',
                    'Offset from transducer, positive means distance from tansducer to water line negative means distance from transducer to keel'],
                    
                    'GST': ['TC time of associated GGA fix',
                    'Total RMS standard deviation of ranges inputs to the navigation solution',
                    'Standard deviation (meters) of semi-major axis of error ellipse',
                    'Standard deviation (meters) of semi-minor axis of error ellipse',
                    'Orientation of semi-major axis of error ellipse (true north degrees)',
                    'Standard deviation (meters) of latitude error',
                    'Standard deviation (meters) of longitude error',
                    'Standard deviation (meters) of altitude error'],
                    
                    'DTM': ['Local datum code.',
                    'Local datum subcode.  May be blank.',
                    'Latitude offset (minutes)',
                    'N or S',
                    'Longitude offset (minutes)',
                    'E or W',
                    'Altitude offset in meters',
                    'Datum name. What\'s usually seen here is "W84", the standard WGS84 datum used by GPS.'],
                    
                    'GSV': ['total number of GSV messages to be transmitted in this group',
                    '1-origin number of this GSV message  within current group',
                    'total number of satellites in view (leading zeros sent)',
                    'satellite PRN number (leading zeros sent)',
                    'elevation in degrees (00-90) (leading zeros sent)',
                    'azimuth in degrees to true north (000-359) (leading zeros sent)',
                    'SNR in dB (00-99) (leading zeros sent) more satellite info quadruples like 4-7 n)'],
                    
                    'AAM': ['Status, BOOLEAN, A = Arrival circle entered',
                    'Status, BOOLEAN, A = perpendicular passed at waypoint',
                    'Arrival circle radius',
                    'Units of radius, nautical miles',
                    'Waypoint ID'],
                    
                    'VHW': ['Degress True',
                    'T = True',
                    'Degrees Magnetic',
                    'M = Magnetic',
                    'Knots (speed of vessel relative to the water)',
                    'N = Knots',
                    'Kilometers (speed of vessel relative to the water)',
                    'K = Kilometers'],
                    
                    'GLC': ['Latitude',
                    'N or S (North or South)',
                    'Longitude',
                    'E or W (East or West)',
                    'Universal Time Coordinated (UTC)',
                    'Status A - Data Valid, V - Data Invalid',
                    'FAA mode indicator (NMEA 2.3 and later)'],
                    
                    'MSS': ['Signal strength (dB 1uV)',
                    'Signal to noise ratio (dB)',
                    'Beacon frequency (kHz)',
                    'Beacon data rate (BPS)',
                    'Unknown integer value'],
                    
                    'GSA': ['Selection mode: M=Manual, forced to operate in 2D or 3D, A=Automatic, 3D/2D',
                    'Mode (1 = no fix, 2 = 2D fix, 3 = 3D fix)',
                    'ID of 1st satellite used for fix',
                    'ID of 2nd satellite used for fix',
                    'ID of 3rd satellite used for fix',
                    'ID of 4th satellite used for fix',
                    'ID of 5th satellite used for fix',
                    'ID of 6th satellite used for fix',
                    'ID of 7th satellite used for fix',
                    'ID of 8th satellite used for fix',
                    'ID of 9th satellite used for fix',
                    'ID of 10th satellite used for fix',
                    'ID of 11th satellite used for fix',
                    'ID of 12th satellite used for fix',
                    'PDOP',
                    'HDOP',
                    'VDOP'],
                    
                    'VDR': ['Degress True',
                    'T = True',
                    'Degrees Magnetic',
                    'M = Magnetic',
                    'Knots (speed of current)',
                    'N = Knots'],
                    
                    'MSK': ['Frequency to use',
                    'Frequency mode, A=auto, M=manual',
                    'Beacon bit rate',
                    'Bitrate, A=auto, M=manual',
                    'Frequency for MSS message status (null for no status)'],
                    
                    'GBS': ['UTC time of the GGA or GNS fix associated with this sentence',
                    'Expected error in latitude (meters)',
                    'Expected error in longitude (meters)',
                    'Expected error in altitude (meters)',
                    'PRN of most likely failed satellite',
                    'Probability of missed detection for most likely failed satellite',
                    'Estimate of bias in meters on most likely failed satellite',
                    'Standard deviation of bias estimate'],
                    
                    'TPC': ['Horizontal distance from the vessel center line',
                    'Meters',
                    'Horizontal distance from the transducer to the trawl along the vessel center line. The value is normally positive assuming the trawl is located behind the vessel.',
                    'Meters',
                    'Depth of the trawl below the surface',
                    'Meters'],
                    
                    'HFB': ['Distance from headrope to footrope',
                    'Meters (0-100)',
                    'Distance from headrope to bottom',
                    'Meters (0-100)'],
                    
                    'ZTG': ['Universal Time Coordinated (UTC)',
                    'Time Remaining',
                    'Destination Waypoint ID'],
                    
                    'MWV': ['Wind Angle, 0 to 360 degrees',
                    'Reference, R = Relative, T = True',
                    'Wind Speed',
                    'Wind Speed Units, K/M/N',
                    'Status, A = Data Valid'],
                    
                    'DCN': ['Decca chain identifier',
                    'Red Zone Identifier',
                    'Red Line Of Position',
                    'Red Master Line Status',
                    'Green Zone Identifier',
                    'Green Line Of Position',
                    'Green Master Line Status',
                    'Purple Zone Identifier',
                    'Purple Line Of Position',
                    'Purple Master Line Status',
                    'Red Line Navigation Use',
                    'Green Line Navigation Use',
                    'Purple Line Navigation Use',
                    'Position Uncertainity',
                    'N = Nautical Miles',
                    'Fix Data Basis - 1 = Normal Pattern - 2 = Lane Identification Pattern - 3 = Lane Identification Transmissions'],
                    
                    'HSC': ['Heading Degrees, True',
                    'T = True',
                    'Heading Degrees, Magnetic',
                    'M = Magnetic'],
                    
                    'OLN': ['Omega Pair 1',
                    'Omega Pair 1',
                    'Omega Pair 1'],
                    
                    'RMB': ['Status, A= Active, V = Void',
                    'Cross Track error - nautical miles',
                    'Direction to Steer, Left or Right',
                    'TO Waypoint ID',
                    'FROM Waypoint ID',
                    'Destination Waypoint Latitude',
                    'N or S',
                    'Destination Waypoint Longitude',
                    'E or W',
                    'Range to destination in nautical miles',
                    'Bearing to destination in degrees True',
                    'Destination closing velocity in knots',
                    'Arrival Status, A = Arrival Circle Entered',
                    'FAA mode indicator (NMEA 2.3 and later)'],
                    
                    'RMC': ['UTC Time',
                    'Status, V=Navigation receiver warning A=Valid',
                    'Latitude',
                    'N or S',
                    'Longitude',
                    'E or W',
                    'Speed over ground, knots',
                    'Track made good, degrees true',
                    'Date, ddmmyy',
                    'Magnetic Variation, degrees',
                    'E or W',
                    'FAA mode indicator (NMEA 2.3 and later)'],
                    
                    'RMA': ['Blink Warning',
                    'Latitude',
                    'N or S',
                    'Longitude',
                    'E or W',
                    'Time Difference A, uS',
                    'Time Difference B, uS',
                    'Speed Over Ground, Knots',
                    'Track Made Good, degrees true',
                    'Magnetic Variation, degrees',
                    'E or W'],
                    
                    'GGA': ['Universal Time Coordinated (UTC)',
                    'Latitude',
                    'N or S (North or South)',
                    'Longitude',
                    'E or W (East or West)',
                    'GPS Quality Indicator, - 0 - fix not available, - 1 - GPS fix, - 2 - Differential GPS fix (values above 2 are 2.3 features) - 3 = PPS fix - 4 = Real Time Kinematic - 5 = Float RTK - 6 = estimated (dead reckoning) - 7 = Manual input mode - 8 = Simulation mode',
                    'Number of satellites in view, 00 - 12',
                    'Horizontal Dilution of precision (meters)',
                    'Antenna Altitude above/below mean-sea-level (geoid) (in meters)',
                    'Units of antenna altitude, meters',
                    'Geoidal separation, the difference between the WGS-84 earth ellipsoid and mean-sea-level (geoid), "-" means mean-sea-level below ellipsoid',
                    'Units of geoidal separation, meters',
                    'Age of differential GPS data, time in seconds since last SC104 type 1 or 9 update, null field when DGPS is not used',
                    'Differential reference station ID, 0000-1023'],
                    
                    'TTM': ['Target Number (0-99)',
                    'Target Distance',
                    'Bearing from own ship',
                    'Bearing Units',
                    'Target Speed',
                    'Target Course',
                    'Course Units',
                    'Distance of closest-point-of-approach',
                    'Time until closest-point-of-approach "-" means increasing',
                    '"-" means increasing',
                    'Target name',
                    'Target Status',
                    'Reference Target'],
                    
                    'PGRME': ['Estimated horizontal position error (HPE),',
                    'M=meters',
                    'Estimated vertical position error (VPE)',
                    'M=meters',
                    'Overall spherical equivalent position error',
                    'M=meters'],
                    
                    'ROT': ['Rate Of Turn, degrees per minute, "-" means bow turns to port',
                    'Status, A means data is valid'],
                    
                    'OSD': ['Heading, degrees true',
                    'Status, A = Data Valid',
                    'Vessel Course, degrees True',
                    'Course Reference',
                    'Vessel Speed',
                    'Speed Reference',
                    'Vessel Set, degrees True',
                    'Vessel drift (speed)',
                    'Speed Units'],
                    
                    'VLW': ['Speed, "-" means downwind',
                    'N = Knots',
                    'Speed, "-" means downwind',
                    'M = Meters per second'],
                    
                    'WPL': ['Transducer Type',
                    'Measurement Data',
                    'Units of measurement',
                    'Name of transducer'],
                    
                    'RTE': ['Total number of messages being transmitted',
                    'Message Number',
                    "Message mode c = complete route, all waypoints w = working route, the waypoint you just left, the waypoint you're heading to, then all the rest", 'Waypoint ID'],
                    
                    'GTD': ['Heading Degrees, true',
                    'T = True'],
                    
                    'GRS': ['TC time of associated GGA fix',
                    '0 = Residuals used in GGA, 1 = residuals calculated after GGA',
                    'Satellite 1 residual in meters',
                    'Satellite 2 residual in meters',
                    'Satellite 3 residual in meters',
                    'Satellite 4 residual in meters (blank if unused)',
                    'Satellite 5 residual in meters (blank if unused)',
                    'Satellite 6 residual in meters (blank if unused)',
                    'Satellite 7 residual in meters (blank if unused)',
                    'Satellite 8 residual in meters (blank if unused)',
                    'Satellite 9 residual in meters (blank if unused)',
                    'Satellite 10 residual in meters (blank if unused)',
                    'Satellite 11 residual in meters (blank if unused)',
                    'Satellite 12 residual in meters (blank if unused)'],
                    
                    'VTG': ['True course over ground (degrees) 000 to 359',
                    'Magnetic course over ground 000 to 359',
                    'Speed over ground (knots) 00.0 to 99.9',
                    'Speed over ground (kilometers) 00.0 to 99.9'],
                    
                    'WCV': ['Distance, Nautical Miles',
                    'N = Nautical Miles',
                    'Distance, Kilometers',
                    'K = Kilometers',
                    'TO Waypoint',
                    'FROM Waypoint'],
                    
                    'PMGNST': ['Firmware version number?',
                    'Mode (1 = no fix, 2 = 2D fix, 3 = 3D fix)',
                    'T if we have a fix',
                    'numbers change - unknown',
                    'time left on the GPS battery in hours',
                    'numbers change (freq. compensation?)',
                    'PRN number receiving current focus'],
                    
                    'STN': ['Talker ID Number'],
                    
                    'MTW': ['Degrees',
                    'Unit of Measurement, Celcius'],
                    
                    'TRF': ['UTC Time',
                    'Date, ddmmyy',
                    'Latitude',
                    'N or S',
                    'Longitude',
                    'E or W',
                    'Elevation Angle',
                    'Number of iterations',
                    'Number of Doppler intervals',
                    'Update distance, nautical miles',
                    'Satellite ID',
                    'Data Validity'],
                    
                    'XTE': ['UTC time (hours, minutes, seconds, may have fractional subsecond)',
                    'Day, 01 to 31',
                    'Month, 01 to 12',
                    'Year (4 digits)',
                    'Local zone description, 00 to +- 13 hours',
                    'Local zone minutes description, apply same sign as local hours'],
                    
                    'TPT': ['Horizontal range relative to target',
                    'Meters (0-4000)',
                    'True bearing to taget (ie. relative north).  Resolution is one degree.',
                    'Separator',
                    'Depth of trawl below the surface',
                    'Meters (0-2000)'],
                    
                    'TPR': ['Horizontal range relative to target',
                    'Meters (0-4000)',
                    'Bearing to target relative to vessel heading.  Resolution is one degree.',
                    'Separator',
                    'Depth of trawl below the surface',
                    'Meters (0-2000)'],
                    
                    'R00': ['waypoint ID'],
                    
                    'DBK': ['Depth, feet',
                    'f = feet',
                    'Depth, meters',
                    'M = meters',
                    'Depth, Fathoms',
                    'F = Fathoms'],
                    
                    'ALM': ['Total number of messages',
                    'Message Number',
                    'Satellite PRN number (01 to 32)',
                    'GPS Week Number',
                    'SV health, bits 17-24 of each almanac page',
                    'Eccentricity',
                    'Almanac Reference Time',
                    'Inclination Angle',
                    'Rate of Right Ascension',
                    'Root of semi-major axis',
                    'Argument of perigee',
                    'Longitude of ascension node',
                    'Mean anomaly',
                    'F0 Clock Parameter',
                    'F1 Clock Parameter'],
                    
                    'RSD': ['Unknown',
                    'Unknown',
                    'Unknown',
                    'Unknown',
                    'Unknown',
                    'Unknown',
                    'Unknown',
                    'Unknown',
                    'Cursor Range From Own Ship',
                    'Cursor Bearing Degrees Clockwise From Zero',
                    'Range Scale',
                    'Range Units',
                    'Unknown'],
                    
                    'RPM': ['Sourse, S = Shaft, E = Engine',
                    'Engine or shaft number',
                    'Speed, Revolutions per minute',
                    'Propeller pitch, % of maximum, "-" means astern',
                    'Status, A means data is valid'],
                    
                    'RSA': ['Starboard (or single) rudder sensor, "-" means Turn To Port',
                    'Status, A means data is valid',
                    'Port rudder sensor',
                    'Status, A means data is valid'],
                    
                    'VWR': ['Wind direction magnitude in degrees',
                    'Wind direction Left/Right of bow',
                    'Speed',
                    'N = Knots',
                    'Speed',
                    'M = Meters Per Second',
                    'Speed',
                    'K = Kilometers Per Hour'],
                    
                    'LCD': ['GRI Microseconds/10',
                    'Master Relative SNR',
                    'Master Relative ECD',
                    'Time Difference 1 Microseconds',
                    'Time Difference 1 Signal Status',
                    'Time Difference 2 Microseconds',
                    'Time Difference 2 Signal Status',
                    'Time Difference 3 Microseconds',
                    'Time Difference 3 Signal Status',
                    'Time Difference 4 Microseconds',
                    'Time Difference 4 Signal Status',
                    'Time Difference 5 Microseconds',
                    'Time Difference 5 Signal Status'],
                    
                    'SFI': ['Total Number Of Messages',
                    'Message Number',
                    'Frequency 1',
                    'Mode 1 x. Checksum'],
                    
                    'APB': ['UTCTime',
                    'Waypoint Latitude',
                    'N = North, S = South',
                    'Waypoint Longitude',
                    'E = East, W = West',
                    'Bearing, True',
                    'T = True',
                    'Bearing, Magnetic',
                    'M = Magnetic',
                    'Nautical Miles',
                    'N = Nautical Miles',
                    'Waypoint ID'],
                    
                    'VBW': ['Longitudinal water speed, "-" means astern',
                    'Transverse water speed, "-" means port',
                    'Status, A = Data Valid',
                    'Longitudinal ground speed, "-" means astern',
                    'Transverse ground speed, "-" means port',
                    'Status, A = Data Valid'],
                    
                    'DBS': ['Depth, feet',
                    'f = feet',
                    'Depth, meters',
                    'M = meters',
                    'Depth, Fathoms',
                    'F = Fathoms'],
                    
                    'APA': ['Status V = LORAN-C Blink or SNR warning V = general warning flag or other navigation systems when a reliable fix is not available',
                    'Status V = Loran-C Cycle Lock warning flag A = OK or not used',
                    'Cross Track Error Magnitude',
                    'Direction to steer, L or R',
                    'Cross Track Units (Nautic miles or kilometers)',
                    'Status A = Arrival Circle Entered',
                    'Status A = Perpendicular passed at waypoint',
                    'Bearing origin to destination',
                    'M = Magnetic, T = True',
                    'Destination Waypoint ID',
                    'checksum'],
                    
                    'DBT': ['Depth, feet',
                    'f = feet',
                    'Depth, meters',
                    'M = meters',
                    'Depth, Fathoms',
                    'F = Fathoms'],
                    
                    'ZFO': ['Universal Time Coordinated (UTC)',
                    'Elapsed Time',
                    'Origin Waypoint ID']}